package com.ptkc.constants;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: Mr.Jiao
 * @date: 2018年11月07日
 */
public class Page<T> {

    /**
     * 总条数
     */
    private long total;

    /**
     * 总页数
     */
    private int totalPage;

    /**
     * 当前页
     */
    private int page;

    /**
     * 分页大小
     */
    private int pageSize;

    /**
     * 数据
     */
    private List<T> rows;

    public long getTotal() {
        return total;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public int getPage() {
        return page;
    }

    public int getPageSize() {
        return pageSize;
    }

    public List<T> getRows() {
        return rows;
    }


    public Page(long total, int page, int pageSize, List<T> rows) {
        this.total = total;
        this.page = page;
        this.pageSize = pageSize;
        this.rows = rows;
        this.totalPage = (int)(this.total % this.pageSize > 0 ? this.total / this.pageSize + 1 : this.total / this.pageSize);
    }

    public Page(int page, int pageSize) {
        this.total = 0;
        this.page = page;
        this.pageSize = pageSize;
        this.rows = new ArrayList<>();
        this.totalPage = 0;
    }
}
